#pragma once


#include <Arduino.h>

#include "mega128_specific.hpp"
#include "scheduler_basic.hpp"

// ioxx
#include "pin/avr_arduino.hpp"


namespace m128 = mega128_specific;

using TimeSource = scheduler_basic::ArduinoMsSource;
using TimeType = TimeSource::TimeType;
using SchedulerType = scheduler_basic::DelayCallback3<TimeSource, 8>;


// ====================================  Globals  ====================================

extern SchedulerType dcb;


// ====================================  Logger  ====================================


#ifndef NO_SERIAL_LOG

    // 用来输出调试日志的串口对象
    #define SerialLog Serial


template <typename T>
inline void log_line(T value) {
    SerialLog.println(value);
}


template <typename T>
inline void log_line(const char* str, T value) {
    SerialLog.print(str);
    SerialLog.println(value);
}


inline void begin_log() {
    SerialLog.begin(115200);
    SerialLog.println("<< BEGIN LOG >>");
}

#else

template <typename T>
inline void log_line(T value) {}

template <typename T>
inline void log_line(const char* str, T value) {}

inline void begin_log() {}

#endif